<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="renderer" content="webkit">
    <meta name="referrer" content="never">
    <meta name="robots" content="noindex, nofollow">
    <meta charset="utf-8">
    <title>合同详情</title>
    <script src="/assets/signature/jquery-3.6.0.min.js"></script>
    <script src="/assets/signature/jSignature.min.js"></script>
    <style>
        body {
            margin: 0;
            padding: 0;
        }

        iframe {
            border: 0;
            width: 100%;
            height: calc(100vh - 80px);
            /*height: 100vh;*/
        }

        .btns {
            text-align: center;
            height: 80px;
            /*background: red;*/

        }

        button {
            font-size: 20px;
        }

        #signature {
            border: 1px solid #ccc;
            height: 500px;
        }
    </style>
</head>

<body>
<iframe src="https://www.pfile.com.cn/api/profile/onlinePreview?url=https://crm.szhxvip.com/{$customer.contract_url}"></iframe>
<!--<div id="signature"></div>-->

<div class="btns">
    {if$customer && $customer.signature_url}
    已完成签名
    {else}
    <button id="com">确定签字</button>
    {/if}
</div>
<!--<button id="clearBtn">清空</button>-->
<!--<button id="exportBtn">导出图片</button>-->
<!--<button id="submitBtn">提交</button>-->
<script>
    $(function () {
        $('#com').click(() => {
            window.location.href = "{:url('/index/index/details/customer_id/'.$customer_id)}"
        })


        var $signature = $("#signature");
        $signature.jSignature();
        // var $signature = $("#signature").jSignature();
        // 清空
        $("#clearBtn").click(function () {
            $signature.jSignature("reset");
        });
        // 保存图片
        $("#exportBtn").click(function () {
            var dataUrl = $signature.jSignature("getData");
            var link = document.createElement("a");// 创建一个虚拟链接
            link.href = dataUrl;
            link.download = "signature.png"; // 设置下载的文件名，可以根据需要进行修改
            link.click();// 执行点击事件触发下载
        });
        // 提交按钮
        $("#submitBtn").click(function () {
            var dataUrl = $signature.jSignature("getData");
            console.log(dataUrl);
            // 发送数据
            // $.ajax({
            //   url: "/",
            //   method: "POST",
            //   data: {
            //     image: dataUrl
            //   },
            //   success: function (response) {
            //     console.log(response);
            //   },
            //   error: function (error) {
            //     console.log(error);
            //   }
            // });
        });
    });
</script>
</body>

</html>
